
mainModule.controller('mainCtrl', ['$scope','$rootScope', '$state','$timeout','jbase','getMsg', 'api',
                                   function($scope,$rootScope, $state,$timeout,jbase,getMsg,api ) {

      $rootScope.loadingTitle=getMsg(Code.LOADING);
    
      $rootScope.loadClosed=function(){}

     jbase.AJAX_FAIL_CALLBACK=function(data){
        $rootScope.error =true;
     }

    if(!$rootScope.user){
      api.login.rsa(function(data){
       if(data.code!=Code.LOGING) $state.go("login");
         $rootScope.user=data.data.user;
      });
      api.res.tree(function(data){
            $rootScope.tree = data;
      });
     
    }

     $scope.logout=function(){
      
         api.login.logout(function(data){
             $state.go('login');
             $rootScope.user=null;
         });
     }

 
   



}]);